﻿using Microsoft.AspNetCore.Mvc;

namespace NET6Demo.WebApi.Controllers
{
    /// <summary>
    /// 文件资源
    /// </summary>
    [ApiController]
    //[ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
    [Route("[controller]/v{version:apiVersion}")]
    public class FileController : ControllerBase
    {
        private readonly ILogger<FileController> _logger;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger"></param>
        public FileController(ILogger<FileController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 文件上传
        /// </summary>
        /// <returns></returns>
        [HttpPost(Name = "File")]
        public JsonResult UploadFile(IFormCollection form)
        {
            return new JsonResult(new
            {
                Success = true,
                Message = "上传成功",
                FileName = form.Files.FirstOrDefault()?.FileName
            });
        }
    }
}
